//
//  DemoController.m
//  NavigationGradienBar
//
//  Created by zhengju on 17/3/31.
//  Copyright © 2017年 俱哥. All rights reserved.
//

#import "DemoController.h"

#import "NavigationGradientBar.h"

@interface DemoController ()<NavigationGradientBarDelegate>
@property (weak, nonatomic) IBOutlet UITableView *tableView;

@property (nonatomic,strong) NavigationGradientBar * navigationBar;
@property (strong, nonatomic) IBOutlet UIView *headerView;

@end

@implementation DemoController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.automaticallyAdjustsScrollViewInsets = NO;
    
    self.navigationBar = [[NavigationGradientBar alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, 64) backImgName:@"返回按钮" gradientImgName:@"红色返回箭头"  middleTitle:@"Demo" delegate:self];
    
    self.navigationBar.beginTitleColor = [UIColor whiteColor];
    self.navigationBar.afterTitleColor = [UIColor blackColor];
    
    self.navigationBar.beginStatusBarDefault = NO;
    self.navigationBar.afterStatusBarDefault = YES;
    
    [self.view addSubview:self.navigationBar];

    self.headerView.frame = CGRectMake(0, 0, ScreenWidth, 400);
    [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"UITableViewCell"];
    self.tableView.tableHeaderView = self.headerView;
}

#pragma mark - UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 50;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    
    UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"UITableViewCell" forIndexPath:indexPath];
    cell.textLabel.text = @"数据数据.........";
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}
#pragma mark - UITableViewDelegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 44;
}
-(void)scrollViewDidScroll:(UIScrollView *)scrollView{
    
    [self.navigationBar navigationGradientBarContentOffset:scrollView.contentOffset.y];
}

#pragma mark NavigationGradientBarDelegate
-(void)backNavigationGradientBar:(NavigationGradientBar *)bar{
    [self.navigationController popViewControllerAnimated:YES];
}
@end
